#!/bin/bash
source ../common/common.sh

echo "===INIT==UBUNTU=ENC==="
sudo echo "SUDO ROOT"

chk_mkdir ~/.config

show t "配置安装/opt/bin等目录"
show i "建立/opt/bin等目录"
chk_mkdir /opt/bin sudo
chk_mkdir /opt/sbin sudo
chk_mkdir /opt/etc sudo
chk_mkdir /opt/common sudo
chk_mkdir /opt/lib sudo
chk_mkdir /opt/libexec sudo
chk_mkdir /opt/docs sudo

show i "将/opt/bin等目录加入系统路径"
chk_addpath 2 OPT_BIN_PATH		          /opt/bin
chk_addpath 2 OPT_SBIN_PATH		          /opt/sbin
chk_addpath 2 OPT_COMMON_PATH		        /opt/common
if [ -d /opt/lib ]; then
  sudo sh -c 'echo "/opt/lib" >/etc/ld.so.conf.d/optlib.conf'
  if [ -d /opt/service/redis/lib ]; then
    chk_addpath 2 OPT_REDIS_BIN_PATH		/opt/service/redis/bin
    sudo sh -c 'echo "/opt/service/redis/lib" >>/etc/ld.so.conf.d/optlib.conf'
  fi
fi

show i "拷贝相关脚本文件到/opt/bin等目录"
sudo cp ../common/common.sh /opt/common/common.sh
sudo cp ../tools/login.sh /opt/bin/login.sh
sudo cp ../tools/login.sh /opt/bin/autologin.sh
sudo cp ../tools/setpasswd.sh /opt/bin/setpasswd.sh
sudo cp ../vpnssh_proxy/bin/vpn.sh /opt/bin/vpn.sh
sudo cp ../tools/autobackup.sh /opt/bin/autobackup.sh
sudo cp ../vpnssh_proxy/bin/shadowsocks-local-linux64 /opt/bin/shadowsocks-local-linux64
sudo cp ../vpnssh_proxy/bin/config.json /opt/bin/config.json
sudo cp ../vpnssh_proxy/bin/svpn.sh /opt/bin/svpn.sh

show i "配置wget默认支持断点续传"
echo "continue=on" > ~/.wgetrc